using UnityEngine;
using System.Collections;

public class ZigZagMotor : StraightDownMotor 
{
	private int direction = -1;
    Vector3[] randomDirection = new Vector3[] { -Vector3.right, Vector3.right };
    int leftOrRight;
    void Start()
    {
        leftOrRight = Random.Range(0, 2);
        
    }
	protected override void SetDirection (ref Vector3 dir)
	{
		dir += randomDirection[leftOrRight] * direction * HorizontalSpeed * Time.deltaTime;
		base.SetDirection(ref dir);
	}
	
	void OnCollisionEnter(Collision col)
	{
		if(col.gameObject.tag == "LevelBounds")
		{
			direction = -direction;
		}
	}
}
